/**
 * 全局导航跳转工具类
 */
export default class NavigationUtil {
  /**
   * 跳转指定页面
   * @param params
   * @param page
   */
  static goPage(page, params) {
    const navigation = NavigationUtil.navigation;
    if (!navigation) {
      console.log('NavigationUtil navigation can not be null');
    }
    navigation.navigate(page, {...params});
  }

  /**
     * 清空历史记录跳转
     * @param page

    static resetGoPage(navigation,page){
        const  resetAction = NavigationActions.reset({
            index: 0,
            actions: [
                NavigationActions.navigate({routeName: page})
            ]
        });
        navigation.dispatch(resetAction);
    }*/

  /**
   * 返回上一页
   * @param navigation
   */
  static goBack(navigation) {
    navigation.goBack();
  }

  /**
   * 重置到首页
   * @param params
   */
  static resetToHomePage(params) {
    const {navigation} = params;
    navigation.navigate('Main');
  }

  /**
   * 重置到登录
   * @param params
   */
  static resetToLoginPage(params) {
    const {navigation} = params;
    navigation.navigate('Login', {...params});
  }
}
